import instance from '../utils/request'
// 获取文章详情
function getDetailApi (id) {
  return instance({
    url: `/v1_0/articles/${id}`,
    headers: { 'Content-Type': 'application/json' }
  })
}
// 获取评论详情
function getCommentsApi (params) {
  return instance({
    url: '/v1_0/comments',
    params: params,
    headers: { 'Content-Type': 'application/json' }
  })
}
// 关注用户
function followedApi () {
  return instance({
    url: '/v1_0/user/followings',
    method: 'post',
    needToken: true,
    headers: { 'Content-Type': 'application/json' }
  })
}
// 取消关注用户
function notFollowedApi (id) {
  return instance({
    url: `/v1_0/user/followings/${id}`,
    method: 'DELETE',
    needToken: true,
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
}
// 点赞
function starApi (data) {
  return instance({
    url: '/v1_0/article/likings',
    method: 'post',
    data: data,
    needToken: true,
    headers: { 'Content-Type': 'application/json' }
  })
}
// 不喜欢
function dislikeApi (data) {
  return instance({
    url: '/v1_0/article/dislikes',
    method: 'post',
    data: data,
    needToken: true,
    headers: { 'Content-Type': 'application/json' }
  })
}
// 对文章发表评论
function sendCommentsApi (data) {
  return instance({
    url: '/v1_0/comments',
    method: 'post',
    needToken: true,
    headers: { 'Content-Type': 'application/json' },
    data: data
  })
}
export {
  getDetailApi,
  getCommentsApi,
  followedApi,
  notFollowedApi,
  starApi,
  dislikeApi,
  sendCommentsApi
}
